package com.lanou.lenanapp.util;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lanou.lenanapp.R;


/**
 * Created by dllo on 15/11/7.
 */
public class Utils {
        public static Dialog createloadingDialog(Context context,String content){
            LayoutInflater inflater = LayoutInflater.from(context);
            View view = inflater.inflate(R.layout.custom_loading_dialog, null);
            RelativeLayout layout = (RelativeLayout) view.findViewById(R.id.layout);
            ImageView imageView = (ImageView) view.findViewById(R.id.image);
            TextView text = (TextView) view.findViewById(R.id.content);
            text.setText(content);
            Animation animation = AnimationUtils.loadAnimation(context, R.anim.loading_image);
            imageView.startAnimation(animation);
            Dialog dialog = new Dialog(context, R.style.loadingDialog);
            dialog.setContentView(layout, new LinearLayout.LayoutParams(300, 200));
            dialog.setCancelable(true);//返回键能取消dialog
            return dialog;
    }
}
